<?php


namespace app\api\controller;


use app\api\model\Usermodel;
use app\BaseController;

class Login extends  BaseController
{
    public function login(){
        $data = input('post.');
        $mobile = Usermodel::where('mobile',$data['mobile'])->find();
        if (!$mobile){
            return error('该账户不存在');
        }else{
             $password= md5($data['password'].$mobile['salt']) == $mobile['password'];
             if (!$password){
                 return  error('密码错误');
             }else{
                 return  success('登录成功', ['token' => singToken($mobile['id'],$mobile['mobile'])]);
             }
        }
    }
}